home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / prg_casm / pcl4c60.zip / PCL4CUSR.DOC < prev    next >
Text File  |  1996-10-24  |  90KB  |  2,102 lines

  1.  
  2.  
  3.  
  4.                          Personal Communications Library
  5.  
  6.                                For the C Language
  7.  
  8.  
  9.                                      (PCL4C)
  10.  
  11.  
  12.                                  USERS MANUAL
  13.  
  14.  
  15.                                    Version 6.0
  16.  
  17.                                 October 21, 1996
  18.  
  19.  
  20.  
  21.                          This software is provided as-is.
  22.                   There are no warranties, expressed or implied.
  23.  
  24.  
  25.  
  26.  
  27.                                Copyright (C) 1995
  28.                                All rights reserved
  29.  
  30.  
  31.  
  32.                             MarshallSoft Computing, Inc.
  33.                                Post Office Box 4543
  34.                                Huntsville AL 35815
  35.  
  36.  
  37.                              Voice : 205-881-4630
  38.                                FAX : 205|880|0925
  39.                                BBS : 205-880-9748
  40.                              email : info@marshallsoft.com
  41.                           Anon FTP : ftp.marshallsoft.com /marshallsoft
  42.                                web : www.marshallsoft.com
  43.  
  44.  
  45.                                    _______
  46.                               ____|__     |                (R)
  47.                            --+       |    +-------------------
  48.                              |   ____|__  |  Association of
  49.                              |  |       |_|  Shareware
  50.                              |__|   o   |    Professionals
  51.                            --+--+   |   +---------------------
  52.                                 |___|___|    MEMBER
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.      PCL4C Users Manual                                        Page 1
  61.  
  62.                                 C O N T E N T S
  63.  
  64.  
  65.  
  66.        Chapter                                                   Page
  67.  
  68.        1.0 Introduction................................................3
  69.            1.1 User Support............................................4
  70.            1.2 ASP Ombudsman...........................................4
  71.            1.3 A Typical Application...................................5
  72.            1.4 Installation............................................6
  73.        2.0 Library Organization........................................7
  74.            2.1 Configuration...........................................7
  75.            2.2 Initialization & Termination............................7
  76.            2.3 Modem Control & Status..................................8
  77.            2.4 Serial I/O..............................................8
  78.            2.5 Error Detection.........................................9
  79.            2.6 General Support.........................................9
  80.        3.0 Library Overview...........................................10
  81.            3.1 Memory Models..........................................10
  82.            3.2 16-bit Protected Mode..................................11
  83.            3.3 32-bit Protected Mode..................................12
  84.            3.4 Compilers Supported....................................13
  85.            3.5 Using the Library......................................13
  86.            3.6 Application Notes......................................14
  87.            3.7 Compiling & Linking....................................15
  88.        4.0 Talking to Your Modem......................................16
  89.            4.1 Modem Standards........................................16
  90.            4.2 Flow Control...........................................17
  91.            4.3 MODEM_IO functions.....................................17
  92.            4.4 Modem Initialization...................................18
  93.        5.0 Problems...................................................19
  94.        6.0 Serial Communications......................................20
  95.            6.1 Communications Basics..................................20
  96.            6.2 Standard Port Addresses................................21
  97.            6.3 Running 3 or 4 Ports Concurrently......................22
  98.            6.4 Using Multiport Cards..................................23
  99.            6.5 Transmitter Interrupts.................................24
  100.            6.6 RS232 Signals..........................................25
  101.            6.7 National INS8250, INS16450, and INS16550 UARTs.........26
  102.            6.8 Register Summary.......................................27
  103.        7.0 Example Programs...........................................29
  104.        8.0 Legal Issues...............................................30
  105.            8.1 Registration...........................................30
  106.            8.2 License................................................30
  107.            8.3 Warranty...............................................31
  108.        9.0 Summary....................................................32
  109.            9.1 Revision History.......................................32
  110.            9.2 Function Summary.......................................34
  111.            9.3 Further Reading........................................34
  112.       10.0 Other MarshallSoft Computing products for C................35
  113.            10.1 The Personal Protocol Library for C...................35
  114.            10.2 The EMS Expanded Memory Library for C.................35
  115.            10.3 Other Products........................................35
  116.  
  117.  
  118.  
  119.  
  120.      PCL4C Users Manual                                        Page 2
  121.  
  122.       1.0 Introduction
  123.  
  124.       The Personal Communications Library for the C Language (PCL4C) is an
  125.       asynchronous communications library designed for experienced software
  126.       developers programming in C/C++.  Six compilers are supported:
  127.       Microsoft C, Quick C, Borland C, Turbo C, Watcom C, and MIX Power C.
  128.       An IBM PC/XT/AT or compatible is required.  The PCL features:
  129.  
  130.               o Supports 16-bit & 32-bit PROTECTED MODE.
  131.               o SMALL, COMPACT, MEDIUM, LARGE, & FLAT memory models.
  132.               o 38 communications and support functions.
  133.               o Supports the high performance 16550 UART.
  134.               o Supports the PC/4 and PC/8 DigiBoard.
  135.               o Supports the BOCA BB1004, BB1008, and BB2016 boards.
  136.               o Supports hardware (RTS/CTS) flow control.
  137.               o Interrupt driven transmitter & receiver.
  138.               o Supports 300 baud to 115,200 baud.
  139.               o Use IRQ2 through IRQ15 with any UART address.
  140.               o Supports COM1 thru COM4 (COM20 in registered version).
  141.               o Adjustable receive queues from 8 bytes to 32 KB.
  142.               o Control-BREAK error exit.
  143.               o 18 communications error conditions trapped.
  144.               o Allows 4 ports to run concurrently (more with multiport).
  145.               o Complete modem control & status.
  146.               o Written in assembly language for small size & high speed.
  147.               o Terminal program featuring ASCII (with XON/XOFF), XMODEM,
  148.                 YMODEM, & YMODEM-G.
  149.  
  150.          Why should you buy PCL4C ?  Several good reasons are:
  151.  
  152.         COMPLETE - PCL4C is complete since it provides absolute control of
  153.                    the serial ports (including the 16550 UART).
  154.  
  155.          COMPACT - PCL4C is very compact at less than 10 KB.  Your
  156.                    application doesn't carry a lot of excess code.
  157.  
  158.             FAST - PCL4C is fast since it will run at 38400 baud on even
  159.                    slow 8088 PCs (4.77 MHZ) and at 115200 baud on most
  160.                    everything else.
  161.  
  162.          SUPPORT - If you get stuck, you talk to the programmer that wrote
  163.                    the code, not a person hired to answer the phone.
  164.  
  165.              BBS - A BBS is available (to 14400 baud, N81) in order to
  166.                    provide immediate support as necessary.
  167.  
  168.       NEWSLETTER - We publish a quarterly newsletter "Comm Talk", which
  169.                    discusses serial communications problems and solutions.
  170.  
  171.            PRICE - You get PCL4C for a very reasonable price!
  172.  
  173.         UPGRADES - Once you buy PCL4C, you can always update to the most
  174.                    recent version very inexpensively ($25 plus shipping).
  175.  
  176.  
  177.  
  178.  
  179.  
  180.      PCL4C Users Manual                                        Page 3
  181.  
  182.       1.1 User Support
  183.  
  184.       We want you to be successful in developing your applications using
  185.       PCL4C! We depend on our customers to let us know what they need in a
  186.       communications library.  This means we are committed to providing the
  187.       best communications library that we can. If you have any suggestions
  188.       or comments, please let us know!
  189.  
  190.       We provide customer support for registered customers by voice, BBS,
  191.       email, and US mail.
  192.  
  193.       If you are having a problem using PCL4C, call us at 205-881-4630
  194.       between 1:30 PM and 9:30 PM (CST) Monday through Friday. You can also
  195.       call at other times and leave a message, and call back later for a
  196.       reply. We cannot return phone calls.
  197.  
  198.       However, we can only answer questions with respect to using the
  199.       PCL4C library. We cannot help you program your application, but we'll
  200.       be glad to discuss it with you.
  201.  
  202.       You may also call our User Support BBS (2400 to 14400 baud, no
  203.       parity, 8 data bits, 1 stop bit) at 205-880-9748 and leave a message
  204.       (address it to the SYSOP).  We will usually have a reply ready for
  205.       you within 24 hours.
  206.  
  207.       The BBS is available 24 hours per day. All files are in standard ZIP
  208.       format. The BBS will contain the latest shareware version of all
  209.       MarshallSoft Computing products as well as related files such as:
  210.  
  211.                   BUGS.ZIP     -  Bug report.
  212.                   PRODUCTS.ZIP -  List of all shareware products.
  213.  
  214.       The MarshallSoft Computing, Inc.  newsletter "Comm Talk" is published
  215.       quarterly.  It discusses various communications problems and
  216.       solutions using PCL4C as well as related information.
  217.  
  218.       The latest copy of our newsletter can be found on our support BBS,
  219.       anonymous FTP site, or on our Web site.
  220.  
  221.          BBS      : 205-880-9748            (file area "Newsletters")
  222.          Anon FTP : ftp.marshallsoft.com    (directory  /marshallsoft)
  223.          Web site : www.marshallsoft.com
  224.  
  225.       1.2 ASP Ombudsman
  226.  
  227.       MarshallSoft Computing, Inc.  is a member of the Association of
  228.       Shareware Professionals (ASP).  ASP wants to make sure that the
  229.       shareware principle works for you.  If you are unable to resolve a
  230.       shareware-related problem with an ASP member by contacting the member
  231.       directly, ASP may be able to help. The ASP Ombudsman can help you
  232.       resolve a dispute or problem with an ASP member, but does not provide
  233.       technical support for members' products. Please write to the ASP
  234.       Ombudsman at 545 Grover Road, Muskegon, MI USA 49442-9427, Fax
  235.       616-788-2765, or send a CompuServe message via CompuServe Mail to
  236.       ASP Ombudsman 70007,3536.
  237.  
  238.  
  239.  
  240.      PCL4C Users Manual                                        Page 4
  241.  
  242.       1.3 A Typical Application
  243.  
  244.       In general, there are two classes of applications that use a
  245.       communications library like PCL4C - those that use a modem to connect
  246.       to the outside world and those that connect directly to a peripheral
  247.       device. In either case, a typical (real mode) application program
  248.       using PCL4C might look like the following code outline:
  249.  
  250.            +---------------------------------------------------+
  251.            | #include  "pcl4c.h"                               |
  252.            |                                                   |
  253.            | void main(void)                                   |
  254.            | {                                                 |
  255.            |  ...                                              |
  256.            |  /* initialize serial comm  system  */            |
  257.            |  SioRxBuf(Port,AllocSeg(1024),Size1024);          |
  258.            |  SioTxBuf(Port,AllocSeg(128),Size128);            |
  259.            |  SioParms(Port,NoParity,OneStopBit,WordLength8);  |
  260.            |  SioReset(Port,Baud2400);                         |
  261.            |                                                   |
  262.            |  ...application code...                           |
  263.            |                                                   |
  264.            |  /* terminate serial comm system  */              |
  265.            |  SioDone(Port);                                   |
  266.            | }                                                 |
  267.            +---------------------------------------------------+
  268.  
  269.       In the above example, SioRxBuf is called to set up the a 1024 byte
  270.       receive buffer; SioTxBuf is called to set up a 128 byte transmit
  271.       buffer; SioParms is called to set up the parity, stop bit count, and
  272.       word length; SioReset is called to set the baud rate to 2400 and
  273.       reset the UART (Univeral Asynchronous Receiver / Transmitter).
  274.  
  275.       The function AllocSeg allocates a buffer of specified size on the
  276.       far heap and returns the segment SEG such that SEG:0 points to the
  277.       buffer.  The function AllocSeg is part of the example code and can be
  278.       found in the file ALLOCSEG.C.
  279.  
  280.       Before leaving your application, SioDone is called to restore the
  281.       prior state of the serial communications system.
  282.  
  283.       If you are using a modem, you also need to be concerned about
  284.       initializing your modem correctly and handling any required flow
  285.       control. Refer to the "Talking to Your Modem" chapter for detailed
  286.       information.
  287.  
  288.       The communication library has been pre-assembled to library files:
  289.  
  290.               PCL4C_S.LIB : Small memory model.
  291.               PCL4C_C.LIB : Compact memory model.
  292.               PCL4C_M.LIB : Medium memory model.
  293.               PCL4C_L.LIB : Large memory model.
  294.               PCL4C_P.LIB : 16-bit Protected mode [Large model].
  295.               PCL4C32.OBJ : 32-bit Protected Mode [Flat model].
  296.               PCL4C_S.MIX : MIX PowerC small memory model.
  297.               PCL4C_M.MIX : MIX PowerC medium memory model.
  298.               PCL4C_L.MIX : MIX PowerC large memory model.
  299.  
  300.      PCL4C Users Manual                                        Page 5
  301.  
  302.       1.4 Installation
  303.  
  304.       (1) Before installation of PCL4C, your C compiler should already be
  305.       installed on your system and tested. If you are not familiar with
  306.       makefiles, refer to your compiler manual. If you are using the
  307.       interactive environment for Quick C or Turbo C, be sure to compile
  308.       with the memory model corresponding to the PCL4C library used, and
  309.       include the correct library in the project file.  Examine the file
  310.       "FILES.LST" for a list of all the distribution files.
  311.  
  312.       (2) Make a backup copy of your distribution disk.  Put your original
  313.       distribution disk in a safe place.
  314.  
  315.       (3) Create a work directory on your work disk (normally your
  316.       harddisk).  For example, to create a work directory named PCL4C, we
  317.       first log onto the work disk and then type:
  318.  
  319.                           MKDIR PCL4C
  320.  
  321.       (4) Copy all the files from your backup copy of the distribution
  322.       disk to your work directory.  For example, to copy from the A: drive
  323.       to your work directory, we type:
  324.  
  325.                           CD PCL4C
  326.                           COPY A:*.*
  327.  
  328.        (5) [OPTIONAL] Delete the makefiles that you won't need.  For
  329.       example, if you use the Microsoft C compiler, then you want to keep
  330.       all makefiles ending *._M_ but can delete those for Turbo C (*._T_),
  331.       Quick C (*._Q_), and MIX Power C (*.PRJ).  You may also delete any
  332.       libraries that you won't need.
  333.  
  334.       (6) Compile SIMPLE.C and link with the appropriate PCL4C library
  335.       (PCL4C_S.LIB for all but Power C which must use PCL4C_S.MIX).
  336.       Makefiles (or project files) are provided for each of the supported
  337.       compilers.
  338.  
  339.               a) Microsoft C/C++:  MAKE SIMPLE._M_
  340.               b) Microsoft QuickC: MAKE SIMPLE._Q_
  341.               c) Borland C/C++:    MAKER -fSIMPLE._B_
  342.                  (32-bit)          MAKER -fSIMPLE32._B_
  343.               d) Turbo C/C++:      MAKE -fSIMPLE._T_
  344.               e) MIX Power C:      PC/E SIMPLE.PRJ
  345.               f) WATCOM C/C++:     WMAKE -f SIMPLE._W_
  346.                  (32-bit)          WMAKE -f SIMPLE32._W_
  347.  
  348.       SIMPLE.C [or SIMPLE32.C] should compile without any problems as all
  349.       example code has been tested with each of the supported compilers.
  350.  
  351.       (7) The recommended way to test SIMPLE is to run it on two computers
  352.       connected by a null modem cable.  Whatever is typed on one computer
  353.       should be displayed on the other.
  354.  
  355.       SIMPLE can also be tested by connecting your port to a modem.
  356.       Transmitting a "AT" to the modem should result in an "OK" being
  357.       received.
  358.  
  359.  
  360.      PCL4C Users Manual                                        Page 6
  361.  
  362.       2.0 Library Organization
  363.  
  364.       The PCL4C library is organized into six categories of functions.
  365.       Refer to the PCL Reference Manual (PCL4C.REF) for details on
  366.       individual functions.
  367.  
  368.       2.1 Configuration
  369.  
  370.       There are three functions in the configuration category.  SioPorts
  371.       sets the number of PC and DigiBoard (or BOCA board) ports. SioUART is
  372.       used to change the UART base address for a communications port to a
  373.       non-standard address, while SioIRQ is used to assign a nonstandard
  374.       IRQ line to a port.  (See chapter 6, Serial Communications for more
  375.       details on standard UART addresses and IRQ lines).
  376.  
  377.       The configuration functions SioPorts, SioUART and SioIRQ must be
  378.       called before calling any other library functions.  Be very careful
  379.       in using these functions.  Remember that your serial hardware must
  380.       support the UART and IRQ that you specify.  Always test any new
  381.       configuration immediately.
  382.  
  383.       SioPorts -  Sets number of PC and DigiBoard (or BOCA board) ports.
  384.       SioUART  |  Sets the UART base address.
  385.       SioIRQ   -  Assigns an IRQ line to a port.
  386.  
  387.       THE IRQ GOLDEN RULE: You may open (via SioReset) only one port per
  388.       IRQ (except for the DigiBoard and BOCA board).
  389.  
  390.       2.2 Initialization & Termination
  391.  
  392.       There are eight functions in the initialization and termination
  393.       category. Together, SioParms, SioFIFO, SioRxBuf, SioTxBuf, and
  394.       SioReset initialize your serial communications system.  Your
  395.       application must call SioRxBuf and SioTxBuf before calling SioReset,
  396.       and SioReset must be called before any serial I/O processing can be
  397.       done.
  398.  
  399.       After initialization, SioParms and SioBaud can be called to change
  400.       the communications parameters without resetting the serial port.
  401.       SioFlow can be called to enable hardware flow control.  SioFIFO can
  402.       be called to set the interrupt level for the 16550 FIFO.
  403.  
  404.       Before exiting from your application, SioDone must be called.
  405.       Failure to call SioDone can crash your system later.
  406.  
  407.       SioRxBuf   : Sets up receive buffer.
  408.       SioTxBuf   : Sets up transmitter buffer.
  409.       SioFIFO    : Sets the interrupt level for the INS16550.
  410.       SioParms   : Sets parity, stop bits, and word length.
  411.       SioReset   : Initialize a serial port for processing.
  412.       SioDone    : Terminates further serial processing.
  413.       SioBaud    : Sets the baud rate of the selected port.
  414.       SioFlow    : Enables / disables hardware flow control.
  415.  
  416.  
  417.  
  418.  
  419.  
  420.      PCL4C Users Manual                                        Page 7
  421.  
  422.       2.3 Modem Control & Status
  423.  
  424.       There are nine functions in the modem control and status category
  425.       which provide your application with complete control over the status
  426.       and control bits of your modem.
  427.  
  428.       There are two modem control bits, "Data Terminal Ready" (DTR) and
  429.       "Request To Send" (RTS).  These bits can be read, set, or cleared by
  430.       SioDTR and SioRTS.
  431.  
  432.       There are four modem status bits, "Data Set Ready" (DSR), "Clear To
  433.       Send" (CTS), "Ring Indicator" (RI), and "Data Carrier Detect" (DCD).
  434.       SioModem can read any of the modem status bits.  SioDSR, SioCTS,
  435.       SioRI, and SioDCD can only read their respective modem status bit.
  436.       SioGetDiv reads the baud rate divisor register so the baud rate can
  437.       be determined.
  438.  
  439.       Refer to the chapter entitled "RS232 Signals" for a discussion of
  440.       each of the control and status bits.
  441.  
  442.       SioDTR    : Set, clear, or read the Data Terminal Ready (DTR) bit.
  443.       SioRTS    : Sets, clears, or reads the Request to Send (RTS) line.
  444.       SioModem  : Reads the modem status register.
  445.       SioDSR    : Reads the Data Set Ready (DSR) modem status bit.
  446.       SioCTS    : Reads the Clear to Send (CTS) modem status bit
  447.       SioDCD    : Reads the Data Carrier Detect (DCD) modem status bit.
  448.       SioRI     : Reads the Ring Indicator (RI) modem status bit.
  449.       SioRead   : Reads the contents of the 7 UART registers.
  450.       SioGetDiv : Reads the baud rate divisor registers.
  451.  
  452.       2.4 Serial I/O
  453.  
  454.       There are eleven library functions in the serial I/O category.
  455.       Together, these functions give the programmer complete control over
  456.       serial I/O.  Higher level functions such as protocols and smart modem
  457.       communications can be completely implemented in terms of these
  458.       functions.  Refer to the example code.
  459.  
  460.       SioGetc, SioGets, SioPutc, and SioPuts perform all the actual serial
  461.       I/O. SioUnGetc "ungets" the last serial byte read.  SioRxClear clears
  462.       the receive queue while SioTxClear clears the transmit queue.
  463.       SioTxFlush flushes the transmit queue.  SioLine can be used to test
  464.       for UART errors. SioRxQue returns the number of bytes in the receive
  465.       queue while SioTxQue returns the number of bytes in the transmit
  466.       queue.
  467.  
  468.       SioGetc    : Reads the next character from the serial line.
  469.       SioGets    : Reads a buffer of characters from the serial line.
  470.       SioLine    : Reads the line status register.
  471.       SioPutc    : Transmit a character over a serial line.
  472.       SioPuts    : Transmit a buffer of characters over a serial line.
  473.       SioRxClear : Clears the RX buffer.
  474.       SioRxQue   : Returns the number of characters in the RX queue.
  475.       SioTxClear : Clears the TX buffer.
  476.       SioTxFlush : Flushes the TX buffer by restarting TX interrupts.
  477.       SioTxQue   : Returns the number of characters in the TX queue.
  478.       SioUnGetc  : "Un:gets" (puts back) a specified character.
  479.  
  480.      PCL4C Users Manual                                        Page 8
  481.  
  482.       2.5 Error Detection
  483.  
  484.       There are four functions in the error detection category.  They are
  485.       concerned with detecting or reporting communications errors.  Use of
  486.       these functions can make your application significantly more robust.
  487.  
  488.       SioBrkKey can be used as an "emergency" exit from your application.
  489.       SioBrkSig can read or modify the UART break bit.  This is useful for
  490.       signalling the remote system that a fatal condition has occurred.
  491.       SioLoopBack can be used to test the integrity of your UART.  SioError
  492.       displays a error message corresponding to an error code returned from
  493.       a PCL4C function (every PCL4C function returns a code).
  494.  
  495.       SioBrkKey   : Returns !0 if CTL-BREAK was pressed [16-bit lib only].
  496.       SioBrkSig   : Asserts, cancels, or detects the RS232 BREAK  signal.
  497.       SioError    : Displays error in text [32-bit lib uses SioErr32.C].
  498.       SioLoopBack : Performs a UART loopback test. [16-bit lib only].
  499.  
  500.       2.6 General Support
  501.  
  502.       There are three functions in the general support category.  They are
  503.       as follows:
  504.  
  505.       SioInfo     : Returns library information such as version number.
  506.       SioStats    : Return port specific statistics [32-bit only].
  507.       SioDelay    : Delays one or more tics (18.2 tics per second).
  508.       SioTimer    : Returns the number of system clock tics.
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.      PCL4C Users Manual                                        Page 9
  541.  
  542.       3.0 Library Organization
  543.  
  544.       3.1 Memory Models
  545.  
  546.       Because of the segmented architecture of the INTEL CPU, there are
  547.       four real mode memory organizations possible for computer programs.
  548.       These are named the SMALL, COMPACT, MEDIUM, and LARGE memory models,
  549.       which correspond to the four combinations of "near" and "far"
  550.       addresses for code and data.
  551.  
  552.       Each (real mode) executable is composed of one or more segments,
  553.       where each segment can occupy from one byte to 64 KB of memory.  A
  554.       "near" address is a 16 bit offset in a segment, whereas a "far"
  555.       address consists of both a 16 bit segment value and a 16 bit offset.
  556.  
  557.       In the small memory model, code and data each occupy one segment.
  558.       Thus, near addresses are allocated for both code and data.
  559.  
  560.       In the compact memory model, code occupies one segment while data
  561.       may occupy multiple segments.  Near addresses are allocated for code
  562.       but far addresses are allocated for data.
  563.  
  564.       In the medium memory model, data occupies one segment while code may
  565.       occupy multiple segments.  Near addresses are allocated for data but
  566.       far addresses are allocated for code.
  567.  
  568.       In the large memory model, data and code each occupy multiple
  569.       segments.  Far addesses are allocated for both code and data. Thus,
  570.       both code and data can use as many segments as required.
  571.  
  572.       Refer to your compiler manual for a discussion of the memory models
  573.       supported by your compiler.
  574.  
  575.       PCL4C is organized as four separate libraries (PCL4C_S.LIB,
  576.       PCL4C_C.LIB, PCL4C_M.LIB and PCL4C_L.LIB) corresponding to the four
  577.       standard memory models. For the MIX Power C compiler, the small,
  578.       medium, and large models are provided. Lastly, there is the 16-bit
  579.       and 32-bit protected mode model which is linked into protected mode
  580.       applications.
  581.  
  582.          MODEL      CODE      DATA     Library
  583.          Small      Near      Near     PCL4C_S.LIB & PCL4C_S.MIX
  584.          Compact    Near      Far      PCL4C_C.LIB
  585.          Medium     Far       Near     PCL4C_M.LIB & PCL4C_M.MIX
  586.          Large      Far       Far      PCL4C_L.LIB & PCL4C_L.MIX
  587.          Protected  Far       Far      PCL4C_P.LIB [16-bit PM only].
  588.          Flat       Near      Near     PCL4C32.OBJ [32-bit PM only].
  589.  
  590.       However, one can always use the large memory model library
  591.       PCL4C_L.LIB with any memory model application code by explicitly
  592.       declaring the PCL4C procedures to be FAR (by prefixing "far" before
  593.       the name of each function in the PCL4C.H file) and declaring your
  594.       receive buffer to be FAR.  If you are compiling with the HUGE memory
  595.       mode (real mode), link with PCL4C_L.LIB.
  596.  
  597.  
  598.  
  599.  
  600.      PCL4C Users Manual                                        Page 10
  601.  
  602.       3.2 16-Bit Protected Mode
  603.  
  604.       16-Bit Protected Mode programming takes advantage of the segmented
  605.       architecture of 286 and up Intel processors.  In contrast to normal
  606.       real mode programming which limits programs to an address space of 1
  607.       MB (1024 KB), 16-bit protected mode allows up to 16 MB. Protected
  608.       mode also offers some measure of protection of one program from
  609.       another.
  610.  
  611.       A program that can execute in protected mode under DOS requires three
  612.       modules:
  613.  
  614.       (1) A DPMI (DOS Protected Mode Interface) server loaded in memory.
  615.       Execute the real mode program DPMI.EXE to determine if a DPMI server
  616.       is loaded.
  617.  
  618.       (2) A protected mode runtime C library linked to your program.
  619.  
  620.       (3) A 16-bit DOS extender which provides protected mode equivalents
  621.           for:
  622.  
  623.           a) A subset of DOS interrupt 21H calls.
  624.           b) A subset of BIOS calls.
  625.  
  626.       The Personal Communications Library (PCL4C_P.LIB) supports 16-bit
  627.       protected mode. The application program must be compiled with a C/C++
  628.       compiler that supports protected mode.  The Borland PowerPack for DOS
  629.       provides all the required modules, although the library can be used
  630.       by any DOS extender that provides the three required components as
  631.       outlined above.
  632.  
  633.       Examine the example program PMSIMPL.C, which is a (16-bit) protected
  634.       mode version of the normal DOS based SIMPLE.C. Compare it to
  635.       SIMPLE.C to see the differences necessary to run in protected mode.
  636.  
  637.       In particular, note the manner in which memory is allocated for use
  638.       in PCL. The transmit and receive buffers must be allocated in
  639.       conventional DOS memory (the first 1MB) since serial interrupts can
  640.       occur during both protected mode and real mode.
  641.  
  642.       Also notice that memory should be free after calling SioDone but
  643.       before exiting:
  644.  
  645.       Examine the makefile (PMSIMPLE._B_) used to compile PMSIMPLE.C using
  646.       the Borland compiler and Borland's PowerPack for DOS.
  647.  
  648.       The program SELFTEST.C can also be compiled for protected mode by
  649.       using the makefile PM_SELF._B_.
  650.  
  651.       For more information on protected mode, refer to your DOS extender
  652.       such as the Borland Power Pack.
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.      PCL4C Users Manual                                        Page 11
  661.  
  662.       3.3 32-Bit Protected Mode
  663.  
  664.       32-bit Protected Mode programming takes advantage of the 32-bit flat
  665.       memory architecture of 386 and up Intel processors.  In contrast to
  666.       real mode programming which limits programs to an address space of
  667.       one MB, a 32-bit Protected Mode program can address four GB.
  668.  
  669.       The 32-bit flat memory model uses 48-bit addesses: a 16-bit selector
  670.       plus a 32-bit offset. The selectors are not usually modified by the
  671.       application code, although the DOS extender and PCL4C32 do manipulate
  672.       them.
  673.  
  674.       32-bit Protected Mode programming requires a 386 (or higher) CPU, a
  675.       C/C++ compiler that can generate 32-bit code, and a 32-bit DOS
  676.       extender which supports the DPMI standard. PCL4C32 has been tested
  677.       with two 32-bit compilers: Borland 4.5 (using the Borland Power Pack
  678.       extender 32RTM) and WATCOM 10.5 & 10.6 (using the DOS4GW extender
  679.       which comes with the WATCOM compiler). Other 32-bit DOS extenders may
  680.       also work provided that DPMI services are available.
  681.  
  682.       If you are shopping for a 32-bit compiler, we recommend WATCOM. Their
  683.       DOS extender (DOS4GW) is very stable and WATCOM even has technical
  684.       support (no credit card or 900 number required!).
  685.  
  686.       You must have a DPMI server loaded in order to use the 32-bit PCL4C
  687.       library. There are several options. If you are using Windows 3.X or
  688.       Windows 95, simply drop into a DOS box since Windows itself requires
  689.       DPMI. A better solution is to configure your memory manager (386Max,
  690.       etc.) to provide DPMI support, typically by disabling EMS memory.
  691.       Refer to your memory manager's manual.
  692.  
  693.       Execute the real mode program DPMI.EXE to determine if a DPMI server
  694.       is loaded.
  695.  
  696.       Examine the two 32-bit example programs SIMPLE32.C and SELF32.C. The
  697.       corresponding makefiles are SIMPLE32._B_, SIMPLE32._W_, SELF32._B_,
  698.       and SELF32._W_. Note that a 0 can be passed as the second argument
  699.       to SioRxBuf and SioTxBuf which will cause PCL4C32 to allocate all
  700.       required memory itself.
  701.  
  702.       The shareware version of PCL4C is limited to 4 ports and can not
  703.       execute for more than 5 minutes at any one time without having to
  704.       restart the application. The registered version supports up to 20
  705.       ports and has no shareware reminder screen or any time limits. The
  706.       assembly language source code for the PCL4C32 library is not
  707.       provided.
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.      PCL4C Users Manual                                        Page 12
  721.  
  722.       3.4 Compilers Supported
  723.  
  724.       At this time, six C compilers are supported by PCL4C.
  725.  
  726.               (1)  Microsoft C Compiler.
  727.               (2)  Quick C Compiler.
  728.               (3)  Turbo C Compiler.
  729.               (4)  Borland C Compiler [also 32-bit with Power Pack].
  730.               (5)  MIX Power C Compiler
  731.               (6)  Watcom C compiler [also 32-bit].
  732.  
  733.       The Microsoft C Compiler supports all memory models.  Just be careful
  734.       to link with the PCL4C library that corresponds to the memory model
  735.       used.  Recall that the small memory model is the default.  Examine
  736.       the (small model) makefiles *._M_ for the Microsoft compiler.
  737.  
  738.       The Microsoft Quick C Compiler supports all memory models, but be
  739.       careful to link with the PCL4C library that corresponds with the
  740.       memory model used. Recall that the small memory model is the default
  741.       for the command line compiler (QCL) while the medium memory model is
  742.       the default for the interactive compiler environment.  Examine the
  743.       (small model) makefiles *._Q_ for the Microsoft Quick C compiler.
  744.  
  745.       The Borland and Turbo C Compilers also support all memory models. Be
  746.       sure to link with the correct PCL4C library corresponding to the
  747.       memory model used. Examine the (small model) makefiles *._T_ for the
  748.       Turbo C compiler and *._B_ for the Borland compiler.
  749.  
  750.       The MIX Power C Compiler supports the small, medium, and large
  751.       memory models. However, older versions of Power C only support the
  752.       small model.  Examine the (small model) project batch files *.PRJ for
  753.       the Power C Compiler.
  754.  
  755.       Other compilers may also work with one or more of the PCL4C libraries
  756.       but have not been tested. Give us a call if you have any difficulty.
  757.  
  758.       3.5 Using the Library
  759.  
  760.       Please examine the PCL4C.H file (PCL4C32.H for 32-bit). Note that
  761.       COM1 is defined as port zero, not port one.  The user must assume the
  762.       responsibilty for passing the correct information when calling PCL4C
  763.       functions.
  764.  
  765.       If there are any conflicts between PCL4C definitions and those in
  766.       other libraries, the PCL4C definitions can be changed in the PCL4C.H
  767.       file and any file that uses the definition. There is no change
  768.       necessary for the library code itself.
  769.  
  770.       The PCL4C libraries (16 and 32 bit) contain no references to any
  771.       runtime libraries. Only BIOS and MSDOS functions are called.
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.      PCL4C Users Manual                                        Page 13
  781.  
  782.       3.6 Application Notes
  783.  
  784.       3.6.1 Terminal Programs
  785.  
  786.       The "terminal program" is the most common class of communications
  787.       program.  It is used to call up a BBS or on-line service such as
  788.       CompuServe, America On-Line, etc.  Refer to the programs SIMPLE and
  789.       LOGIN in section 7 for examples of simple terminal programs.
  790.  
  791.       A more sophisticated terminal program featuring ASCII, XMODEM,
  792.       YMODEM, and ZMODEM protocol file transfers can be found in our sister
  793.       product -- The Personal Protocol Libray (PPL4C).  Source code is
  794.       included in the shareware distribution for everything except ZMODEM
  795.       and the script intepreter.
  796.  
  797.       3.6.2 Door Programs
  798.  
  799.       In order to write a door program which "takes over" a serial port
  800.       without resetting the port or changing the baud rate, call SioReset
  801.       with NORESET as the second argument rather than the baud rate. Call
  802.       SioGetDiv to get the baud rate divisor if the baud rate must be
  803.       determined. Be sure to call SioDone before returning to the invoking
  804.       program.  Refer to the SPAWN.C and DOOR.C example programs.  Also be
  805.       sure to free any memory that you may have allocated in your door
  806.       program before exiting.
  807.  
  808.       3.6.3 BBS Programs
  809.  
  810.       If you are designing a BBS program (also known as HOST programs),
  811.       consider using 16550 UARTS.  You should also choose a multiport card
  812.       such as the DigiBoard or BOCA board if you wish to run more than 4
  813.       ports simultaneously.
  814.  
  815.       If you are using an error correcting modem, then you should be sure
  816.       to set flow control and fix your baud rate at the highest possible
  817.       transfer rates.  For 14,400 modems, this means 19200 or 38400. You
  818.       may need a 16550 UART in order to run at the higher speed.
  819.  
  820.       If you are using an older multi-speed modem (say 1200, 2400, 4800,
  821.       9600) that doesn't use flow control, you should change your baud rate
  822.       to match the CONNECT message baud rate.
  823.  
  824.       3.6.4 Communicating with Devices
  825.  
  826.       If you will be communicating with a serial device (motor control,
  827.       digitizing tablet, etc.) be sure to (1) not enable flow control
  828.       include unless you are certain that flow control is used by the
  829.       serial device, (2) include a short delay after sending each character
  830.       to the serial device (start with 1/4 second), and (3) set DTR and RTS
  831.       since many devices require DTR to be set before they will respond.
  832.  
  833.       As a first step, try to communicate with the serial device using a
  834.       terminal emulator such as SIMPLE.
  835.  
  836.  
  837.  
  838.  
  839.  
  840.      PCL4C Users Manual                                        Page 14
  841.  
  842.       3.7 Compiling and Linking
  843.  
  844.       Registered users may wish to assemble (16-bit) PCL4C.ASM.  Use the
  845.       /MX switch in order to disable automatic conversion from lower case
  846.       to upper case.  If the /MX switch is not used, then all PCL4C
  847.       function references in C code must be in upper case.
  848.  
  849.               Model    Command
  850.  
  851.               Small    MASM PCL4C /DSMALL_MODEL   /MX;
  852.               Compact  MASM PCL4C /DCOMPACT_MODEL /MX;
  853.               Medium   MASM PCL4C /DMEDIUM_MODEL  /MX;
  854.               Large    MASM PCL4C /DLARGE_MODEL   /MX;
  855.  
  856.       To disable transmitter interrupts, add "/DNO_TBE" to each MASM
  857.       command line above.
  858.  
  859.       For example, to make the (small) model PCL4C.OBJ into a library file:
  860.  
  861.                DEL PCL4C_S.LIB
  862.                LIB PCL4C_S.LIB+PCL4C,PCL4C.MAP;
  863.  
  864.       If you are using the MIX Power C Compiler, create the MIX object
  865.       file (you will need version 1.3 of MIX which has the /_ switch):
  866.  
  867.                MIX /_ PCL4C_S
  868.  
  869.       Similarly with the other memory model libaries.  See the batch files
  870.       MAKE_S.BAT, MAKE_C.BAT, MAKE_M.BAT, and MAKE_L.BAT.  Similiarly for
  871.       MAKE_ST.BAT, MAKE_CT.BAT, MAKE_MT.BAT, and MAKE_LT.BAT.
  872.  
  873.       To compile and link (small model) using:
  874.  
  875.            Microsoft C:   NMAKE SIMPLE._M_
  876.                Quick C:   QCL /AS SIMPLE.C /LINK PCL4C_S.LIB
  877.              Borland C:   MAKER -fSIMPLE._B_
  878.                           MAKE -fSIMPLE32._B_    [32-bit]
  879.                  Turbo:   MAKE -fSIMPLE._T_
  880.            MIX Power C:   PC/E /ms SIMPLE.C PCL4C_S.MIX
  881.               WATCOM C:   WMAKE -f SIMPLE._W_
  882.                           WMAKE -f SIMPLE32._W_  [32-bit]
  883.  
  884.       Makefiles or project files are provided for all example code. Borland
  885.       makefiles end with the extension '._B_', Turbo C makefiles with
  886.       '._T_', Microsoft C makefiles end with '._M_', Microsoft Quick C
  887.       makefiles files end with '._Q_', WATCOM makefiles end with '._W_',
  888.       and Power C project batch files end with '.PRJ'.
  889.  
  890.       The PCL4C libraries may also be used with integrated development
  891.       environments. Place all required files along with the library
  892.       corresponding to the memory model being used into the project file.
  893.       Be sure to select the appropriate memory model, and turn off all case
  894.       sensitivity.
  895.  
  896.  
  897.  
  898.  
  899.  
  900.      PCL4C Users Manual                                        Page 15
  901.  
  902.       4.0 Talking to Your Modem
  903.  
  904.       A modem is used to extend the distance over which you may
  905.       communicate. Without a modem, your RS232 cable is limited to a
  906.       maximum of approximately 50 feet. But with a modem, you can
  907.       communicate literally around the world.
  908.  
  909.       Also refer to Section 4.3 for details on MODEM_IO functions.  These
  910.       functions faciliate communications with modems.
  911.  
  912.       4.1 Modem Standards
  913.  
  914.       Two modems can communicate over a telephone line only if they are
  915.       both using the same signaling frequencies and modulation, which are
  916.       determined by the the modem standards used.  Modem standards can be
  917.       divided into three sets: (1) speed, (2) data compression used, and
  918.       (3) error control.
  919.  
  920.       The Bell standards (103 & 212A) are those of AT&T.  The CCITT (The
  921.       International Consultative Committee for Telephone and Telegraph)
  922.       standards are designated as "V. ".
  923.  
  924.               Speed
  925.  
  926.               Bell 103  :   300 baud
  927.               Bell 212A :  1200 baud
  928.               V.21      :   300 baud
  929.               V.22bis   :  1200 & 2400 baud
  930.               V.32      :  4800 & 9600 baud
  931.               V.32bis   :  4800, 7200, 9600, 12000, and 14400 baud
  932.               V.34      :  through 28800 baud
  933.  
  934.               Data Compression
  935.  
  936.  
  937.               MNP 5     :  Microcom Networking Protocol (proprietary).
  938.               V.42bis   :  International data compression standard.
  939.  
  940.  
  941.               Error Control
  942.  
  943.  
  944.               MNP 2,3,4 :  Three level error correction (public domain).
  945.               V.42      :  International error correction standard.
  946.  
  947.       Most of the newer high speed modems use several of the above
  948.       standards. However, not all combinations of modem makes communicate
  949.       easily with each other, especially at high speeds (9600 and up).
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.      PCL4C Users Manual                                        Page 16
  961.  
  962.       4.2 Flow Control
  963.  
  964.       With modems using data compression, the modem to modem connection
  965.       will run at various speeds depending on the quality of the line.  The
  966.       computer to modem connection will be at a fixed baud rate. Therefore,
  967.       a protocol (flow control) is necessary to synchronize the data flow
  968.       between a modem and the computer to which it is connected.
  969.  
  970.       Two flow control protocols are used by modems which require flow
  971.       control. Software flow control is called "XON/XOFF" and hardware flow
  972.       control is called "RTS/CTS".
  973.  
  974.       4.2.1 Software Flow Control (XON/XOFF)
  975.  
  976.       In XON/XOFF (software) flow control, the computer suspends
  977.       transmitting data if it receives a XOFF character (13 hex) from the
  978.       modem, and continues transmitting when it receives a XON character
  979.       (11 hex).  Similiarly, the computer can signal the modem not to send
  980.       any more data by transmitting a XOFF to it, and can tell the modem to
  981.       continue transmission be sending a XON.
  982.  
  983.       Software flow control cannot be used to transfer binary data since
  984.       binary data may have hex 11 or hex 13 bytes embedded in it. The ASCII
  985.       protocol typically uses XON/XOFF to control display flow while the
  986.       modem may be using RTS/CTS. Refer to the module XONOFF.C.
  987.  
  988.       4.2.2 Hardware Flow Control (RTS/CTS)
  989.  
  990.       In RTS/CTS (hardware) flow control, the RTS line is used by the
  991.       computer to signal the modem , while the CTS line is used by the
  992.       modem to signal the computer.  The RTS line is set OFF by the
  993.       computer to tell the modem to suspend transmission, and set to ON to
  994.       tell the modem to continue transmission.  The CTS line is set to OFF
  995.       by the modem to tell the computer to stop transmitting, and set to ON
  996.       to tell the computer to continue transmitting.
  997.  
  998.       Given the choice, always choose hardware flow control over software
  999.       flow control so that all data transmission is transparent.  If
  1000.       hardware flow control is not the default (which it almost always is),
  1001.       you should modify your modem initialization string to turn hardware
  1002.       flow control on.
  1003.  
  1004.       Hardware flow control is internal to the PCL4C library and is
  1005.       selected by the SioFlow function.
  1006.  
  1007.       4.3 MODEM_IO Functions
  1008.  
  1009.       The file MODEM_IO.C has several functions that ease communicating
  1010.       with your modem.  Look in LOGIN.C for examples of use.
  1011.  
  1012.       ModemSendTo   : Sends string (including control chars) to the modem.
  1013.       ModemWaitFor  : Waits for a string from the modem, passing all else through.
  1014.       ModemQuiet    : Waits for continuous quiet of specified duration.
  1015.       ModemHangup   : Hangs up the modem.
  1016.       ModemCmdState : Goes into the modem's command state.
  1017.       ModemEcho     : Echos all serial incoming bytes to the display.
  1018.  
  1019.  
  1020.      PCL4C Users Manual                                        Page 17
  1021.  
  1022.       4.4 Modem Initialization
  1023.  
  1024.       If your application uses a modem (as opposed to using a null modem
  1025.       cable), then you should always send an initialization string to your
  1026.       modem if it is a programmable modem such as those made by Hayes.
  1027.       Communication programs such as PROCOMM and TELIX always send such a
  1028.       string automatically as soon as they start up.
  1029.  
  1030.       The particular initialization string depends on the make of your
  1031.       modem. Virtually all modems implement the basic Hayes AT command set,
  1032.       and add their own "extended" AT commands.  These extended AT commands
  1033.       vary among modem manufacturers.
  1034.  
  1035.       For AT command set modems the following string (followed by a
  1036.       carriage return) may work:
  1037.  
  1038.            AT E1 S7=60 S11=60 V1 X1 Q0 S0=0
  1039.  
  1040.       Refer to your Modem User's Guide for a full discussion of these
  1041.       commands.  A brief description is as follows:
  1042.  
  1043.            AT     : Modem attention command.
  1044.            E1     : Modem will echo what you send to it.
  1045.            S7=60  : Wait 60 seconds for carrier and/or dial tone.
  1046.            S11=60 : Use 60 milliseconds for tone dialing duration & spacing.
  1047.            V1     : Display result code as words (not numbers).
  1048.            X1     : Use the extended result message (CONNECT XXXX) set.
  1049.            Q0     : Modem returns result codes.
  1050.            S0=0   : Do not answer RING.
  1051.  
  1052.       If your application will answer incoming calls, then set the S0
  1053.       register to the ring on which to automatically answer.
  1054.       Alternatively, use the ATA command to explicitly answer the modem
  1055.       after detecting the RING.
  1056.  
  1057.       If you send the above codes by using SioPutc (as opposed to typing
  1058.       them from the keyboard), then follow these guidelines:
  1059.  
  1060.       (1) Send an initial carriage return before the initialization string.
  1061.  
  1062.       (2) Pause at least two tics (18 tics to the second) after each
  1063.       character sent as your modem needs the time to perform its own
  1064.       internal processing. Pause a little longer if your modem is not
  1065.       accepting your initialization string.
  1066.  
  1067.       (3) Pause two seconds after sending any initialization command such
  1068.       as ATZ or AT&F since your modem must do quite a bit of processing.
  1069.  
  1070.       If you experience any problems in initializing your modem, you
  1071.       should first reset it to factory settings by sending:
  1072.  
  1073.               AT&F
  1074.  
  1075.       Your modem may require more initialization than presented above.
  1076.       Refer to your modem manual for details. If you have a communications
  1077.       program such as ProComm or Telix that is known to initialize your
  1078.       modem correctly, then use the same initialization string.
  1079.  
  1080.      PCL4C Users Manual                                        Page 18
  1081.  
  1082.       5.0 Problems
  1083.  
  1084.       Before developing your application, you should run the example
  1085.       programs. They should all execute correctly.
  1086.  
  1087.       If you have two ports on your computer, connect them together with a
  1088.       null modem cable and run SELFTEST.C. If SELFTEST does not execute
  1089.       properly then there is something wrong with either (1) your serial
  1090.       port hardware, (2) your null modem cable, or (3) you selected ports
  1091.       that are not connected by the null modem cable.
  1092.  
  1093.       Another easy test is to connect the serial port to a modem, and use
  1094.       SIMPLE to send a "AT" to the modem, which should respond with a
  1095.       "OK". If you cannot get your application to run properly, first
  1096.       compile and run the terminal emulator program SIMPLE provided on your
  1097.       distribution disk.
  1098.  
  1099.       If your application does not run but the example programs run
  1100.       correctly, then you have most likely made a programming mistake in
  1101.       your application. MarshallSoft Computing cannot debug your
  1102.       application, especially over the telephone!  However, consider each
  1103.       of the following when searching for an error in your application.
  1104.  
  1105.       1.  Have you included the file PCL4C.H in your application ?
  1106.  
  1107.       2.  Did you link with the correct PCL4C library ?  This is the most
  1108.       probable cause if your application 'hangs' as soon as it starts and
  1109.       you must reboot. The function SioInfo('M') returns the model ID under
  1110.       which the library was assembled.
  1111.  
  1112.       3.  Is your receive buffer large enough ? If you are using 1K data
  1113.       blocks in YMODEM, then your receive buffer should be at least 1K (2K
  1114.       if baud rates above 19200 are to be used).
  1115.  
  1116.       4.  Have you selected too high a baud rate (if you are using a slow
  1117.       PC) ?  If only one COM port is being run, you should be able to run
  1118.       at 38400 baud on 8088 machines and 115200 on most 286s and above.
  1119.  
  1120.       5.  Are you attempting to run another application in the background ?
  1121.       Try running without any other programs running in the background.
  1122.  
  1123.       6.  If you are running two COM ports simultaneously, are you using
  1124.       separate receive and transmit buffers ? (you should).
  1125.  
  1126.       7.  Did SioReset return a zero value ?  If not, then you must call
  1127.       SioReset again. See SIMPLE.C for an example.
  1128.  
  1129.       8.  Did you send the proper initialization string to your modem ?
  1130.       Did you set DTR and RTS ? (you should).
  1131.  
  1132.       9.  Do you have more than one COM1 port, etc.  For example, if you
  1133.       have a COM1 port on your motherboard, you cannot add another COM1
  1134.       port or modem board that uses COM1 without first disabling the COM1
  1135.       on the motherboard.
  1136.  
  1137.       10.  Are you passing the proper segment of the receive (and
  1138.       transmit) buffer? See SIMPLE.C for an example.
  1139.  
  1140.      PCL4C Users Manual                                        Page 19
  1141.  
  1142.       6.0 Serial Communications
  1143.  
  1144.       6.1 Communications Basics
  1145.  
  1146.       The heart of serial communications is the UART (Universal
  1147.       Asynchronous Receiver Transmitter).  The IBM PC/XT/AT and compatibles
  1148.       use the INS8250, INS16450, or the INS16550 UART.  The purpose of the
  1149.       UART is:
  1150.  
  1151.       (1) To convert bytes from the CPU (Central Processing Unit), into a
  1152.       serial format by adding the necessary start, stop, and parity bits to
  1153.       each byte before transmission, and to then transmit each bit at the
  1154.       correct baud rate.
  1155.  
  1156.       (2) To convert the incoming stream (at a specified baud rate) of
  1157.       serial bits into bytes by removing the start, stop, and parity bits
  1158.       before being made available to the CPU.
  1159.  
  1160.       The UART is part of the serial interface circuitry which allows the
  1161.       CPU to send and receive signals over the RS232 lines. This can be
  1162.       diagrammed as follows:
  1163.  
  1164.  
  1165.                                  Serial Interface
  1166.                               +-------------------+
  1167.                               |                   |
  1168.            +-----+  Data Bus  |     +------+      |    RS232 Signals
  1169.            | CPU +------------+     | UART |      +----------------*
  1170.            +-----+            |     +------+      |
  1171.                               |                   |
  1172.                               +-------------------+
  1173.  
  1174.  
  1175.       The INS8250/16450/16550 UART is capable of operating in one of two
  1176.       modes, "polled" and "interrupt driven".  The serial communications
  1177.       functions in the BIOS uses the polled method.  In this approach, the
  1178.       CPU is typically in a loop asking the UART over and over again if it
  1179.       has a byte ready.  If it does, the polling code returns the byte.
  1180.       But, if the next byte comes in before the polling code is executing
  1181.       again, then that byte is lost.
  1182.  
  1183.       In the interrupt driven approach, when a byte is received by the
  1184.       UART, an interrupt is generated and the "Interrupt Service Routine"
  1185.       (ISR) is executed immediately, suspending temporarily whatever else
  1186.       is executing.  The ISR then moves the byte to the receive buffer so
  1187.       that your application program can later read it.
  1188.  
  1189.       When a byte is to be transmitted, it is moved to the transmit queue
  1190.       and transmitter interrupts are "kickstarted", which causes an
  1191.       interrupt to be generated each time the transmitter buffer becomes
  1192.       empty. The ISR is invoked, which removes the byte from the
  1193.       transmitter queue and writes it to the UART transmit buffer.
  1194.  
  1195.       Refer to section 6.5 "Transmitter Interrupts", section 6.6 "RS232
  1196.       Signals", and section 6.7 "National INS8250, INS16450 and INS16550
  1197.       UARTs" for further information on these topics.
  1198.  
  1199.  
  1200.      PCL4C Users Manual                                        Page 20
  1201.  
  1202.       6.2 Standard Port Addresses
  1203.  
  1204.       There are a few things to know about how serial communications ports
  1205.       are used by IBM PC/XT/AT and compatible computers.  The standard IBM
  1206.       PC/XT/AT configuration values are as follows:
  1207.  
  1208.               Port    Reg.   IRQ  Vector
  1209.               COM1    3F8H    4     12
  1210.               COM2    2F8H    3     11
  1211.               COM3    3E8H    4     12
  1212.               COM4    2E8H    3     11
  1213.  
  1214.       (Refer to your DigiBoard manual for DigiBoard addresses, or your
  1215.       BOCA board manual for BOCA port addresses).
  1216.  
  1217.       PCL4C assumes the above values.  If necessary, the UART base address
  1218.       can be changed by SioUART, and IRQ lines can be re-assigned by
  1219.       SioIRQ. Remember that each port to be used concurrently must have a
  1220.       unique IRQ line.  Refer to the PCL4C Reference Manual for specific
  1221.       details.
  1222.  
  1223.       When installing new communications cards, the following guidelines
  1224.       are recommended:
  1225.  
  1226.       (1) Be sure to read the documentation for the hardware you are
  1227.       installing.  Pay special attention to UART base addresses and IRQ
  1228.       lines, particularly if trying to set up a non-standard configuration.
  1229.  
  1230.       (2) If you have a choice in base addresses and IRQ lines, always
  1231.       choose standard values as defined above.
  1232.  
  1233.       (3) The first port should be COM1, the second COM2, etc.  Do not
  1234.       skip over any port number if possible.
  1235.  
  1236.       (4) Use SioUART to zero all unused ports (for example, call
  1237.       SioUART(COM4,0) if there is no COM4 port installed).
  1238.  
  1239.       (5) Be carefull not to configure two ports for the same address.
  1240.       This is easier to do than you may believe.
  1241.  
  1242.       (6) Choose an external modem over an internal one.  It is much
  1243.       easier to debug problems with an external modem than an internal one.
  1244.  
  1245.       (7) Select hardware flow control (RTS/CTS) if flow control is
  1246.       required and hardware flow control is not the default.
  1247.  
  1248.       (8) Always test your port as soon as it is installed. Try several
  1249.       programs that use the communications ports.
  1250.  
  1251.       (9) If your serial card has two or more ports, run SELFTEST after
  1252.       configuring it for your new card.
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.      PCL4C Users Manual                                        Page 21
  1261.  
  1262.       6.3 Running 3 or 4 Ports Concurrently
  1263.  
  1264.       PCL4C supports up to 4 serial ports running concurrently (more if
  1265.       you have a DigiBoard or BOCA board).  One free interrupt for each
  1266.       port is required.  Refer to the next section if you have a DigiBoard
  1267.       or BOCA board.
  1268.  
  1269.       Interrupts IRQ4 and IRQ3 are dedicated to the communications ports
  1270.       in a standard IBM PC/XT/AT configuration.  IRQ4 is shared between
  1271.       COM1 and COM3 while IRQ3 is shared between COM2 and COM4.  This means
  1272.       that you can run two ports simultaneously provided that they don't
  1273.       share an interrupt.
  1274.  
  1275.       Suppose that you wish to run 3 ports simultaneously. To begin, you
  1276.       must have 3 UARTs (serial ports) installed on your computer.  Assume,
  1277.       for purposes of this discussion, that COM1 is installed on your
  1278.       motherboard, and that you have purchased a new 2 port serial
  1279.       communications board.
  1280.  
  1281.       You should be able to configure the first serial board port as COM2,
  1282.       which uses IRQ3.  Refer to the manual that came with your serial
  1283.       board.
  1284.  
  1285.       In order to run the third serial port concurrently with the first
  1286.       two, an unused interrupt must be found.  If your serial card can use
  1287.       only IRQ3 and IRQ4, then there is no way to run a third line since
  1288.       IRQ4 and IRQ3 are used for COM1 and COM2.
  1289.  
  1290.       However, many serial cards can use other IRQs, typically IRQ2
  1291.       through IRQ7. Many of the newer serial cards can use IRQs through
  1292.       IRQ15.  Since IRQ5 is normally used for a second printer port, it is
  1293.       a good candidate for COM3.  To use IRQ5 for the third serial port,
  1294.       first set your serial card to use IRQ5 for COM3 (refer to your serial
  1295.       card manual) and then add the following line to your applications
  1296.       code before calling SioReset:
  1297.  
  1298.                 SioIRQ(COM3,IRQ5);
  1299.  
  1300.       Don't forget to disable any device that might use IRQ5, such as a
  1301.       second printer port or a music card.  Unfortunately, there is no easy
  1302.       way to determine that you have no conflicts until you actually
  1303.       attempt to use the IRQ.  If there are conflicts, your system will
  1304.       probably hang and you will have to reboot.
  1305.  
  1306.       To run a fourth serial port, another free IRQ must be found.  On
  1307.       some systems, IRQ7 can be used. To use IRQ7 for the fourth serial
  1308.       port, first set your serial card to use IRQ7 for COM4 and then add:
  1309.  
  1310.                 SioIRQ(COM4,IRQ7);
  1311.  
  1312.       Also note that conflicts are possible with port addresses. You cannot
  1313.       have two cards using the same port address. This problem most often
  1314.       occurs when adding a multiport board since each UART uses 8
  1315.       consecutive port addresses.
  1316.  
  1317.       Of course, you can select any IRQ and UART address that your serial
  1318.       card can generate. But be carefull about IRQ and address conflicts.
  1319.  
  1320.      PCL4C Users Manual                                        Page 22
  1321.  
  1322.       6.4 Using Multiport Cards
  1323.  
  1324.       6.4.1 The DigiBoard
  1325.  
  1326.       PCL4C supports the DigiBoard PC/4 and PC/8. In order to use the
  1327.       DigiBoard, you must configure PCL4C using the SioPorts, SioUART, and
  1328.       SioIRQ functions.
  1329.  
  1330.       Your PC's ports must be partitioned into "standard" PC ports and
  1331.       dumb card ports.  Remember that standard PC ports cannot share IRQs
  1332.       like the DigiBoard (or BOCA board) can. If you are using IRQ4 and
  1333.       IRQ3 for standard PC ports COM1 and COM2, then you cannot use either
  1334.       for DigiBoard ports (try IRQ5 or IRQ7).
  1335.  
  1336.       Suppose that COM1 through COM2 are standard PC ports (using IRQ4 and
  1337.       IRQ3) and you have installed a PC/8 DigiBoard that you wish to use
  1338.       for COM3 through COM10 using interrupt line IRQ5.  You choose to use
  1339.       the recommended DigiBoard UART addresses starting at 0x100:
  1340.  
  1341.       +-------------------------------------------------------------------+
  1342.       | SioPorts(10,COM3,0x140,DIGIBOARD);/* COM3 = 1st DigiBoard port */ |
  1343.       | Address = 0x100;                  /* 1st DigiBoard UART address */|
  1344.       | for(Port=COM3;Port<=COM10;Port++) /* look at each port */         |
  1345.       |   {SioUART(Port,Address);         /* set the UART address */      |
  1346.       |    Address += 8;                  /* compute next address */      |
  1347.       |    SioIRQ(Port,IRQ5);             /* set the DigiBoard IRQ */     |
  1348.       |   }                                                               |
  1349.       +-------------------------------------------------------------------+
  1350.  
  1351.       The DigiBoard uses 0x140 for the status address for odd interrupts
  1352.       and 0x141 for even interrupts.
  1353.  
  1354.       Digiboard may be contacted at 6400 Flying Cloud Drive, Eden Prairie,
  1355.       MN 55344. Telephone 612-943-9020 or FAX 612-943-5398.
  1356.  
  1357.       6.4.2 The BOCA Board
  1358.  
  1359.       PCL4C supports the dumb BOCA board.  As with the DigiBoard, you must
  1360.       configure PCL4C before using the BOCA board.
  1361.  
  1362.       For example, to configure the BOCA BB2016 to use COM1 to COM16, with
  1363.       base addresses starting at 0x100 and IRQ5:
  1364.  
  1365.       +-------------------------------------------------------------------+
  1366.       | SioPorts(16,COM1,0x107,BOCABOARD);/* COM3 = 1st BOCA board port */|
  1367.       | Address = 0x100;                  /* 1st BOCA UART address */     |
  1368.       | for(Port=COM1;Port<=COM16;Port++) /* look at each port    */      |
  1369.       |   {SioUART(Port,Address);         /* set the UART address */      |
  1370.       |    Address += 8;                  /* compute next address */      |
  1371.       |    SioIRQ(Port,IRQ15);            /* set the BOCA IRQ */          |
  1372.       |   }                                                               |
  1373.       +-------------------------------------------------------------------+
  1374.  
  1375.       BOCA may be contacted at BOCA Research, Inc., 6413 Congress Avenue,
  1376.       Suite 130, Boca Raton, FL 33487.  Phone 407-241-8088, FAX
  1377.       407-997-0918.
  1378.  
  1379.  
  1380.      PCL4C Users Manual                                        Page 23
  1381.  
  1382.       6.5 Transmitter Interrupts
  1383.  
  1384.       PCL4C comes assembled for all memory models with transmitter
  1385.       interrupts enabled. PCL4C can also be assembled without transmitter
  1386.       interrupts enabled by including "/DNO_TBE" on the MASM line.
  1387.  
  1388.       When transmitter interrupts are NOT enabled, the following logic
  1389.       occurs everytime SioPutc or SioPuts is called:
  1390.  
  1391.       1.  Wait for the UART transmit buffer to become empty.  The UART
  1392.       transmit buffer may not be empty if the previous transmit is not
  1393.       completed (the UART breaks down the byte & sends 1 bit at a time).
  1394.  
  1395.       2.  When the UART transmit buffer is empty, the byte from the
  1396.       SioPutc or SioPuts call is loaded into the UART transmit buffer and
  1397.       control is returned to the caller.
  1398.  
  1399.       Transmitter interrupts provide a way for your application program to
  1400.       write to the serial port faster than the baud rate, but transmitter
  1401.       interrupts do have several caveats.  To begin, they are slower than
  1402.       polled transmission, although not significantly.  Secondly, they are
  1403.       more complex and thus result in a slightly larger library.
  1404.  
  1405.       The increased complexity of transmitter interrupts is due to the
  1406.       fact that even though transmitter interrupts are enabled, a
  1407.       transmitter interrupt can occur only when the UART transmitter
  1408.       register transitions from not-empty to empty (a byte has just been
  1409.       transmitted). To start the transmitter interrupt process, the first
  1410.       byte in the PCL4C transmitter queue must be transmitted by SioPutc
  1411.       (or SioPuts) rather than by the Interrupt Service Routine (ISR).
  1412.       The remainder of the bytes in the PCL4C transmit queue are
  1413.       transmitted by the ISR when the transmitter interrupt occurs.  This
  1414.       process is called "kickstarting" the transmitter interrupts.
  1415.  
  1416.       When transmitter interrupts are enabled, the following logic occurs
  1417.       everytime SioPutc or SioPuts is called:
  1418.  
  1419.       1.  The byte from SioPutc or bytes from SioPuts are put into the
  1420.       PCL4C transmitter queue.
  1421.  
  1422.       2.  If there is no byte presently being transmitted, then the
  1423.       transmitter interrupt process is kickstarted.
  1424.  
  1425.       3.  Each time a transmitter interrupt occurs, the ISR gains control,
  1426.       removes the next byte from the PCL4C transmitter queue and puts it in
  1427.       the UART transmit register.
  1428.  
  1429.       While you can now call SioPutc and SioPuts faster than the baud
  1430.       rate, bytes are still transmitted at the given baud rate. The
  1431.       advantage of using transmitter interrupts is that an application
  1432.       program can write a string of bytes to the serial transmit queue
  1433.       without having to wait for those bytes to be transmitted before
  1434.       regaining control.
  1435.  
  1436.       When running a streaming protocol (one that doesn't wait for any
  1437.       acknowledgement from the other side), be sure to check for
  1438.       transmitter buffer overflow (eg, SioPutc returns -1).
  1439.  
  1440.      PCL4C Users Manual                                        Page 24
  1441.  
  1442.       6.6 RS-232 Signals
  1443.  
  1444.       RS-232 is the name of the serial data interface standard used to
  1445.       connect computers to modems.  Most IBM compatible computers are built
  1446.       with at least one serial port and use either DB9 (9 pin) or DB25 (25
  1447.       pin) connectors.
  1448.  
  1449.       A summary of these pins and their function follows.  For more
  1450.       detailed information, refer to one of the many books dealing with
  1451.       RS-232 interfacing.
  1452.  
  1453.       Signal Ground Pin 7 (DB25), Pin 5 (DB9)
  1454.  
  1455.       The SG line is used as the common signal ground, and must always be
  1456.       connected.
  1457.  
  1458.       Transmit Data Pin 2 (DB25), Pin 3 (DB9)
  1459.  
  1460.       The TX line is used to carry data from the computer to the modem.
  1461.  
  1462.       Receive Data Pin 3 (DB25), Pin 2 (DB9)
  1463.  
  1464.       The RX line is used to carry data from the modem to the computer.
  1465.  
  1466.       Data Terminal Ready Pin 20 (DB25), Pin 4 (DB9)
  1467.  
  1468.       The DTR line is used by the computer to signal the modem that it is
  1469.       ready. DTR should be set high when talking to a modem.
  1470.  
  1471.       Data Set Ready Pin 6 (DB25), Pin 6 (DB9)
  1472.  
  1473.       The DSR line is used by the modem to signal the computer that it is
  1474.       ready.
  1475.  
  1476.       Request to Send Pin 4 (DB25), Pin 7 (DB9)
  1477.  
  1478.       The RTS line is used to "turn the line around" in half duplex
  1479.       modems, and for hardware flow control in most modems that require
  1480.       flow control.
  1481.  
  1482.       Clear to Send Pin 5 (DB25), Pin 8 (DB9)
  1483.  
  1484.       The CTS line is used to "turn the line around" in half duplex
  1485.       modems, and for hardware flow control in most modems that require
  1486.       flow control.
  1487.  
  1488.       Data Carrier Detect Pin 8 (DB25), Pin 1 (DB9)
  1489.  
  1490.       The DCD line is used by the modem to signal the computer that a data
  1491.       carrier signal is present.
  1492.  
  1493.       Ring Indicator Pin 22 (DB25), Pin 9 (DB9)
  1494.  
  1495.       The RI line is asserted when a 'ring' occurs.
  1496.  
  1497.  
  1498.  
  1499.  
  1500.      PCL4C Users Manual                                        Page 25
  1501.  
  1502.       6.7 National INS8250, INS16450, and INS16550 UARTs
  1503.  
  1504.       The Personal Communications Library is based on the standard
  1505.       National INS8250, INS16450, and INS16550 UARTs. The 8250 was the
  1506.       original UART used in the IBM PC, whereas the 16450 is a faster
  1507.       version found on most 286 & up machines.  The 16550 contains a 16
  1508.       byte FIFO to further reduce communications overhead.  These UARTs
  1509.       consists of 8 register ports as follows:
  1510.  
  1511.            Offset    R/W   Register
  1512.              0       R/W   Receiver (read) / Transmitter (write)
  1513.              1       R/W   Interrupt Enable (read)
  1514.              2       R     Interrupt Identification
  1515.              2       W     FIFO control (INS16550 only)
  1516.              3       R/W   Data Format (Line Control)
  1517.              4       R/W   RS-232 (Modem) Control
  1518.              5       R/W   Line Status
  1519.              6       R/W   RS-232 (Modem) Status
  1520.              7       R/W   Not used.
  1521.  
  1522.       For the standard PC ports (not DigiBoard or BOCA ports), the UART
  1523.       registers are based at 3F8h (COM1), 2F8h (COM2), 3E8h (COM3), and
  1524.       2E8h (COM4).  COM1 and COM3 share interrupt request line IRQ4 while
  1525.       COM2 and COM4 share request line IRQ3. This means that COM1 and COM3
  1526.       can't be used concurrently.  Similarly for COM2 and COM4.
  1527.  
  1528.       If you have a DigiBoard (or BOCA board) installed, you will have 4
  1529.       or more additional ports using INS16450 or INS16550 UARTS.  The
  1530.       default DigiBoard and BOCA board ports are located at 100h, 108h,
  1531.       110h, etc.  Refer to your DigiBoard (or BOCA board) manual.
  1532.  
  1533.       Four sources of interrupts are possible with the 8250 and 16550: (1)
  1534.       receiver error or BREAK, (2) receiver data ready, (3) ready to
  1535.       transmit, and (4) RS232 input.  These four sources of interrupts are
  1536.       summarized as follows:
  1537.  
  1538.          Source of Interrupt        Action Required to Clear
  1539.          Receiver error or BREAK.   Read Line Status register.
  1540.          Receiver data.             Read data from data register.
  1541.          Transmitter Buffer Empty.  Write to data register or read IID reg.
  1542.          RS232 input.               Read Modem Status register.
  1543.  
  1544.       However, PCL4C only enables transmitter and receiver interrupts.
  1545.  
  1546.       If you are not familiar with the INS8250, several good books are
  1547.       available. Refer to the Serial Communications chapter for
  1548.       recommendations.  Although a knowledge of the 8250 is not necessary
  1549.       to use PCL4C, a general knowledge of the theory of asynchronous
  1550.       serial communications is recommended.
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.      PCL4C Users Manual                                        Page 26
  1561.  
  1562.       6.8 Register Summary
  1563.  
  1564.       REG 0 : Data Register
  1565.  
  1566.       Reading from the data register fetches the next input byte, once it
  1567.       is ready. Writing to the data register transmits the byte written to
  1568.       it over the serial line.
  1569.  
  1570.       REG 1 : Interrupt Enable 
  1571.  
  1572.       The Interrupt Enable register enables each of four types of
  1573.       interrupts when the appropriate bit is set to a one.
  1574.  
  1575.          bit 3 : Enable interrupt on RS232 input.
  1576.          bit 2 : Enable interrupt on receiver error or break.
  1577.          bit 1 : Enable interrupt on transmitter buffer empty (TBE).
  1578.          bit 0 : Enable interrupt on received data (RxRDY).
  1579.  
  1580.       REG 2 : Interrupt Identification (IID)
  1581.  
  1582.       Reading the Interrupt Identification (read only) register once an
  1583.       interrupt has occurred identifies the interrupt as follows:
  1584.  
  1585.          Bit 2  Bit 1  Bit 0  Priority    Interrupt
  1586.            0      0      1      none      none
  1587.            1      1      0      0 (high)  Serialization or break.
  1588.            1      0      0      1         Received data.
  1589.            0      1      0      2         Transmitter Buffer Empty.
  1590.            0      0      0      3 (low)   RS232 Input.
  1591.  
  1592.       In the INS16650, REG 2 (write only) is also the FIFO control
  1593.       register.  Writing bits 6 & 7 will set the FIFO trigger level
  1594.       (number of bytes received before an interrupt is generated).
  1595.  
  1596.       Bit 7  Bit 6   Trigger             Bit 7  Bit 6   Trigger
  1597.        0      0      1 byte               1      0      8 bytes
  1598.        0      1      4 bytes              1      1      14 bytes
  1599.  
  1600.       REG 3 : Line Control
  1601.  
  1602.       RS232 line parameters are selected by writing to this register.
  1603.  
  1604.          bit 7    : DLAB = 0
  1605.          bit 6    : BREAK on(1), off(0).
  1606.          bits 5-3 : Parity None(000),ODD(001),EVEN(011),MARK(101),SPACE(111)
  1607.          bit 2    : One stop bit(0), two stop bits(1).
  1608.          bits 1-0 : Data bits = 5 (00), 6(01), 7(10), 8(11).
  1609.  
  1610.       When the Divisor Latch Access Bit (DLAB) is 1, registers 0 and 1
  1611.       become the LS and MS bytes of the Baud Rate Divisor registers.
  1612.  
  1613.          Baud   Divisor      Baud  Divisor      Baud  Divisor
  1614.           300    0180        4800   0018       38400   0003
  1615.          1200    0060        9600   000C       57600   0002
  1616.          2400    0030       19200   0006      115200   0001
  1617.  
  1618.  
  1619.  
  1620.      PCL4C Users Manual                                        Page 27
  1621.  
  1622.       REG 4 : Modem Control
  1623.  
  1624.       RTS, DTR, loopback testing, and General Purpose Outputs #1 and #2 are
  1625.       controlled by the Modem Control register as follows:
  1626.  
  1627.          bit 4 : Enable local loopback.
  1628.          bit 3 : Enable GP02. Necessary for 8250 interrupts.
  1629.          bit 2 : Enable GP01.
  1630.          bit 1 : Set / clear RTS.
  1631.          bit 0 : Set / clear DTR.
  1632.  
  1633.       REG 5 : Line Status
  1634.  
  1635.       Reading the Line Status register provides status information as
  1636.       follows (1 for TRUE, 0 for FALSE) :
  1637.  
  1638.          bit 6 : Transmitter Empty.
  1639.          bit 5 : Transmitter Buffer Empty (TBE).
  1640.          bit 4 : BREAK detect.
  1641.          bit 3 : Framing error.
  1642.          bit 2 : Parity error.
  1643.          bit 1 : Overrun error.
  1644.          bit 0 : Data Ready.
  1645.  
  1646.       REG 6 : Modem Status
  1647.  
  1648.       Reading the Modem Status register provides the following status
  1649.       information (1 for TRUE, 0 for FALSE) :
  1650.  
  1651.          bit 7 : DCD status.
  1652.          bit 6 : RI status.
  1653.          bit 5 : DSR status.
  1654.          bit 4 : CTS status.
  1655.          bit 3 : Delta DCD status.
  1656.          bit 2 : Delta RI status.
  1657.          bit 1 : Delta DSR status.
  1658.          bit 0 : Delta CTS status.
  1659.  
  1660.       The delta bits (bits 0 through 3) are set whenever one of the status
  1661.       bits (bits 4 through 7) changes (from 0 to 1 or from 1 to 0) since
  1662.       the last time that the Modem Status register was read. Reading the
  1663.       Modem Status register clear the delta bits.
  1664.  
  1665.       REG 7 : Scratch Register
  1666.  
  1667.       There is no function associated with register 7.  It does not exist
  1668.       in early versions of the 8250.
  1669.  
  1670.  
  1671.  
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.      PCL4C Users Manual                                        Page 28
  1681.  
  1682.       7.0 Example Programs
  1683.  
  1684.       Six (real mode) example programs are include with PCL4C.  In
  1685.       addition, the Personal Protocol Library for C (PPL4C) includes the
  1686.       terminal program TERM which features ASCII, XMODEM, YMODEM, and
  1687.       ZMODEM protocol transfers.  Complete source code is included in the
  1688.       shareware product for all of the protocols above except ZMODEM.  In
  1689.       order to get ZMODEM source, PPL4C must be registered.
  1690.  
  1691.       7.1 MINIMAL
  1692.  
  1693.       MINIMAL is the simpliest possible communications program. It
  1694.       displays on the screen what it reads from the serial port and
  1695.       transmits over the serial line what is typed at the keyboard.  COM1
  1696.       and 9600 baud are hard coded for simplicity.
  1697.  
  1698.       7.2 SIMPLE
  1699.  
  1700.       SIMPLE is a simple terminal program. It operates like MINIMAL,
  1701.       except that both a port and a baud rate can be specified. For
  1702.       example. SIMPLE32.C is the 32-bit equivalent.
  1703.  
  1704.            SIMPLE 1 9600
  1705.  
  1706.       7.3 LOGIN
  1707.  
  1708.       LOGIN is programmed to dial our support BBS (205-880-9748) and log
  1709.       on as GUEST. Start LOGIN like SIMPLE by providing a COM port and a
  1710.       baud rate. For example,
  1711.  
  1712.            LOGIN 1 38400
  1713.  
  1714.      7.4 SPAWN and DOOR
  1715.  
  1716.       The SPAWN program is the same as the SIMPLE program except that it
  1717.       spawns DOOR when the user types a '$'. For example, to start SPAWN on
  1718.       COM3, type
  1719.  
  1720.            SPAWN 3
  1721.  
  1722.       The DOOR program is also the same as SIMPLE except that it can "take
  1723.       over" a serial port without changing any of the port parameter.
  1724.       Exiting DOOR returns to the invoking program (SPAWN).
  1725.  
  1726.       7.5 SELFTEST
  1727.  
  1728.       The SELFTEST.C [or SELF32.C] program is designed to test serial
  1729.       ports provided that one port (with a loopback adapter) or two ports
  1730.       (connected together with a null-modem adapter) are avaiable. SELFTEST
  1731.       can also be used to test your multiport board.
  1732.  
  1733.       For example, to test PC port COM1 against COM2, type:
  1734.  
  1735.            SELFTEST PC 1 2
  1736.  
  1737.       SELFTEST may need to be configured for non-standard PC ports or your
  1738.       multiport board. Refer to the SELFTEST source code for more info.
  1739.  
  1740.      PCL4C Users Manual                                        Page 29
  1741.  
  1742.       8.0 Legal Issues
  1743.  
  1744.       8.1 Registration
  1745.  
  1746.       If you wish to register the PCL4C library (which also includes the
  1747.       32-bit protected mode version), please send $75 plus $5 S&H ($10
  1748.       outside of North America) to:
  1749.  
  1750.            MarshallSoft Computing, Inc.
  1751.            Post Office Box  4543
  1752.            Huntsville AL 35815
  1753.  
  1754.       The $75 price is good for one year from the date on the title page of
  1755.       the manual. Call for the current price after one year.
  1756.  
  1757.       Multiple copies are available: $55 for 3 to 9, $45 for 10 to 19, and
  1758.       $35 for 20 or more. A site license is also available for $675
  1759.       (includes 20 sets of printed documentation). We pay shipping.
  1760.  
  1761.       We accept American Express, MasterCard, and VISA (account number,
  1762.       expiration date, exact name on your card, and complete card billing
  1763.       address required), checks in US dollars drawn on a US bank, purchase
  1764.       orders (POs) from recognized US schools and companies listed in Dun &
  1765.       Bradstreet, and COD (street address and phone number required) within
  1766.       the USA (plus an additional $4.50 COD charge).
  1767.  
  1768.       You can also order PCL4C from The Public Software Library (PSL) in
  1769.       Houston Texas with your American Express, MasterCard, VISA, or
  1770.       Discover card by calling 800-242-4PSL (from overseas: 713-524-6394)
  1771.       or by FAX at 713-524-6398 or by CompuServe at [71355,470].  THESE
  1772.       NUMBERS ARE FOR ORDERING ONLY. The product number for PCL4C is 10908.
  1773.       Please have your credit card billing address ready.
  1774.  
  1775.       If you wish to update from an older version of PCL4C, send $25 plus
  1776.       $5 S&H ($10 outside of North America).  Updates must be ordered
  1777.       directly from MarshallSoft Computing.
  1778.  
  1779.       The registered package includes:
  1780.  
  1781.          o  Small, Compact, Medium, Large, 16-bit PM  & 32-bit PM libs.
  1782.          o  COM1 thru COM20 supported for all libs.
  1783.          o  Assembler source code for the library [16-bit only].
  1784.          o  Printed Users and Reference Manuals.
  1785.          o  Telephone, FAX, and BBS support for one year.
  1786.  
  1787.       Print the file INVOICE.DOC if an invoice is needed. The registered
  1788.       user will receive the latest version of PCL4C shipped by two day
  1789.       priority mail (packet airmail overseas).  A 3.5" diskette is provided
  1790.       unless a 5.25" diskette is requested.
  1791.  
  1792.  
  1793.  
  1794.  
  1795.  
  1796.  
  1797.  
  1798.  
  1799.  
  1800.      PCL4C Users Manual                                        Page 30
  1801.  
  1802.       8.2 License
  1803.  
  1804.       MarshallSoft Computing, Inc. grants the registered user of PCL4C the
  1805.       right to use one copy of the PCL4C library (in object form) on a
  1806.       single computer in the development of any software product (other
  1807.       than libraries such as PCL4C).  The user may not use the library on
  1808.       more than one computer at the same time.  The source code for the
  1809.       library (PCL4C.ASM) is copyrighted by MarshallSoft Computing and may
  1810.       not be released in whole or in part.
  1811.  
  1812.       Products developed using the registered version of PCL4C or PCL4C32
  1813.       may include the object form of the library and may be distributed
  1814.       royalty free.
  1815.  
  1816.       Under no circumstances can PCL4C or PCL4C32 be used for any
  1817.       commercial purpose without registration.
  1818.  
  1819.       8.3 Warranty
  1820.  
  1821.       MARSHALLSOFT COMPUTING, INC.  DISCLAIMS ALL WARRANTIES RELATING TO
  1822.       THIS SOFTWARE, WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
  1823.       LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  1824.       A PARTICULAR PURPOSE, AND ALL SUCH WARRANTIES ARE EXPRESSLY AND
  1825.       SPECIFICALLY DISCLAIMED.  NEITHER MARSHALLSOFT COMPUTING, INC. NOR
  1826.       ANYONE ELSE WHO HAS BEEN INVOLVED IN THE CREATION, PRODUCTION, OR
  1827.       DELIVERY OF THIS SOFTWARE SHALL BE LIABLE FOR ANY INDIRECT,
  1828.       CONSEQUENTIAL, OR INCIDENTAL DAMAGES ARISING OUT OF THE USE OR
  1829.       INABILITY TO USE SUCH SOFTWARE EVEN IF MARSHALLSOFT COMPUTING, INC.
  1830.       HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES OR CLAIMS.  IN NO
  1831.       EVENT SHALL MARSHALLSOFT COMPUTING, INC.'S LIABILITY FOR ANY SUCH
  1832.       DAMAGES EVER EXCEED THE PRICE PAID FOR THE LICENSE TO USE THE
  1833.       SOFTWARE, REGARDLESS OF THE FORM OF THE CLAIM.  THE PERSON USING THE
  1834.       SOFTWARE BEARS ALL RISK AS TO THE QUALITY AND PERFORMANCE OF THE
  1835.       SOFTWARE.
  1836.  
  1837.       Some states do not allow the exclusion of the limit of liability for
  1838.       consequential or incidental damages, so the above limitation may not
  1839.       apply to you.
  1840.  
  1841.       This agreement shall be governed by the laws of the State of Alabama
  1842.       and shall inure to the benefit of Marshallsoft Computing, Inc.  and
  1843.       any successors, administrators, heirs and assigns.  Any action or
  1844.       proceeding brought by either party against the other arising out of
  1845.       or related to this agreement shall be brought only in a STATE or
  1846.       FEDERAL COURT of competent jurisdiction located in Madison County,
  1847.       Alabama. The parties hereby consent to in personam jurisdiction of
  1848.       said courts.
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854.  
  1855.  
  1856.  
  1857.  
  1858.  
  1859.  
  1860.      PCL4C Users Manual                                        Page 31
  1861.  
  1862.       9.0 Summary
  1863.  
  1864.       9.1 Revision History
  1865.  
  1866.       Version 1.0 - 14 January 1991 - original release.
  1867.  
  1868.       Version 1.1 - 11 March 1991
  1869.          o  Added SioUnGetc function to library.
  1870.  
  1871.       Version 1.2 - 1 June 1991
  1872.          o  SioParms bug - could not call before SioReset.
  1873.          o  SioReset bug - was not saving & restoring all regs.
  1874.  
  1875.       Version 1.3 - 1 July 1991
  1876.          o  Added NORESET option to SioReset.
  1877.          o  Added SioDSR, SioCTS, SioDCD, SioLoopBack, and SioRI.
  1878.  
  1879.       Version 2.0 - 1 Nov 1991
  1880.          o  Reorganized as four memory model libraries.
  1881.          o  Added SioModel function to library.
  1882.          o  Added support for Quick C and Power C.
  1883.  
  1884.       Version 2.1 - 1 Dec 1991
  1885.          o  Fixed bug due to Microsoft Assembler (MASM 5.0,5.1) error.
  1886.  
  1887.       Version 3.0 - 15 Jan 1992
  1888.          o  Added SioUART function.
  1889.          o  Added "UART undefined" error code.
  1890.          o  Added "Bad or missing UART" error code.
  1891.          o  Added "Port already enabled" error code.
  1892.          o  Added "Cannot enable both COM1 & COM3 ..." error code.
  1893.          o  Fixed several minor bugs (using new automated testing).
  1894.  
  1895.       Version 3.1 - 1 March 1992
  1896.          o  Added SioFIFO (INS16550 support).
  1897.          o  Added SioIRQ function.
  1898.          o  Increased maximum receive buffer size to 32K bytes.
  1899.  
  1900.       Version 3.2 - 1 May 1992
  1901.          o  Modified SioReset so that it no longer clears DTR & RTS.
  1902.          o  Modified SioModel & renamed to SioInfo.
  1903.          o  Fixed bug in SioDone when using 2 ports simultaneously.
  1904.          o  Added SioFlow to library.
  1905.          o  Added YMODEM-G protocol to TERM program.
  1906.  
  1907.       Version 3.3 - 3 August 1992
  1908.          o  Fixed bug in SioUnGet when using 2 ports simultaneously.
  1909.          o  Add SioRead function.
  1910.  
  1911.       Version 3.4 - 4 Jan 1993
  1912.          o  Library modified to use up to four ports simultaneously.
  1913.          o  SioIRQ was modified to include a third argument.
  1914.          o  EXAMPORT utility distributed to registered users.
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.      PCL4C Users Manual                                        Page 32
  1921.  
  1922.       9.1 Revision History (continued)
  1923.  
  1924.       Version 3.5 - 15 May 1993
  1925.          o  Supports dumb DigiBoards ( PC/4 and PC/8).
  1926.          o  Two new error traps added ("No such IRQ" & "No such ISR").
  1927.          o  ASCII file transfer protocol added to TERM (with XON/XOFF).
  1928.  
  1929.       Version 4.0 - 18 Oct 1993
  1930.          o  The library supports transmitter interrupts.
  1931.          o  Corrects bug in Ver 3.5 requiring calling SioIRQ for COM3/4.
  1932.          o  All example code compiles with supported C++ compilers.
  1933.          o  The SioIRQ function has been simplified.
  1934.  
  1935.       Version 4.1 - 1 May 1994
  1936.          o  Transmitter FIFO enabled.
  1937.          o  Minor internal modifications.
  1938.          o  Supports dumb BOCA boards (BB1004, BB1008, & BB2016).
  1939.          o  Port definition extented to COM16.
  1940.  
  1941.       Version 4.2 - 1 Sept 1994
  1942.          o  A flow control bug was fixed.
  1943.          o  SioGetDiv function added.
  1944.          o  SioRxBuf & SioTxBuf function modified.
  1945.  
  1946.       Version 4.3 - 15 March 1995
  1947.          o  BREAK detection bug fixed,
  1948.          o  Port definitions extended to COM20.
  1949.          o  Support for IRQ8 through IRQ15.
  1950.          o  Line status bits preserved.
  1951.  
  1952.       Version 5.0 - 20 November 1995
  1953.          o  Supports Protected Mode
  1954.          o  Renamed SioRxFlush to SioRxClear.
  1955.          o  Renamed SioTxFlush to SioTxClear.
  1956.          o  Added SioTxFlush
  1957.          o  Added more choices in SioInfo.
  1958.          o  Removed SioCrtWrite (use putch instead).
  1959.          o  Removed SioKeyPress (use kbhit instead).
  1960.          o  Removed SioKeyRead  (use getch instead).
  1961.          o  Added SioGets & SioPuts.
  1962.  
  1963.       Version 6.0 - 21 October 1996
  1964.          o Only force 15 bytes (not 16) into TX side FIFO.
  1965.          o Handles simultaneous BOCA interrupts under all conditions.
  1966.          o Added 32-bit library!
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.      PCL4C Users Manual                                        Page 33
  1981.  
  1982.       9.2 Function Summary
  1983.  
  1984.       Refer to the PCL4C Reference Manual (PCL4C.REF) for detailed
  1985.       information on the communications and support functions.  A one line
  1986.       summary of each function follows:
  1987.  
  1988.       SioBaud     Sets the baud rate of the selected port.
  1989.       SioBrkKey   Returns non-zero if the Control-BREAK key was pressed.
  1990.       SioBrkSig   Asserts, cancels, or detects BREAK signal.
  1991.       SioCTS      Reads the Clear to Send (CTS) modem status bit.
  1992.       SioDCD      Reads the Data Carrier Detect (DCD) modem status bit.
  1993.       SioDelay    Delays one or more tics (18 tics per second).
  1994.       SioDone     Terminates further serial processing.
  1995.       SioDSR      Reads the Data Set Ready (DSR) modem status bit.
  1996.       SioDTR      Set, clear, or read the Data Terminal Ready (DTR) bit.
  1997.       SioError    Displays error in text.
  1998.       SioFIFO     Sets the interrupt level for the INS16550.
  1999.       SioFlow     Enables / disables hardware flow control.
  2000.       SioGetc     Reads the next character from the serial line.
  2001.       SioGets     Reads a buffer of characters from the serial line.
  2002.       SioGetDiv   Reads the baud rate divisor registers.
  2003.       SioInfo     Returns library information (version number, etc.)
  2004.       SioIRQ      Assigns an IRQ line to a port.
  2005.       SioLine     Reads the line status register.
  2006.       SioLoopBack Performs a UART loopback test.
  2007.       SioModem    Reads the modem status register.
  2008.       SioParms    Sets parity, stop bits, and word length.
  2009.       SioPorts    Sets # ports, 1st DigiBoard / BOCA port & status reg.
  2010.       SioPutc     Transmits a character over a serial line.
  2011.       SioPuts     Transmits a buffer of characters over a serial line.
  2012.       SioRead     Reads any of 7 UART ports.
  2013.       SioReset    Initialize a serial port for processing.
  2014.       SioRI       Reads the Ring Indicator (RI) modem status bit.
  2015.       SioRTS      Sets, clears, or reads the Request to Send (RTS) line.
  2016.       SioRxClear  Clears the receive buffer.
  2017.       SioRxBuf    Sets up receive buffer.
  2018.       SioRxQue    Returns the number of characters in the receive queue.
  2019.       SioTimer    Returns the number of system clock tics.
  2020.       SioTxBuf    Sets up transmit buffer.
  2021.       SioTxClear  Clears the transmit buffer.
  2022.       SioTxFlush  Restarts transmitter interrupts thus flushing the TX queue.
  2023.       SioTxQue    Returns the number of characters in the transmit queue.
  2024.       SioUART     Sets the UART base address.
  2025.       SioUnGetc   "Un-gets" (puts back) a specified character.
  2026.  
  2027.       9.3 Further Reading
  2028.  
  2029.       The best way to learn about serial communications is to read a good
  2030.       book on the subject. Several good texts are available.  Two that I
  2031.       like are:
  2032.  
  2033.       (1) C Programmers's Guide to Serial Communications by Joe Campbell
  2034.       (SAMS)
  2035.  
  2036.       (2) Mastering Serial Communications by Peter Gofton (SYBEX).
  2037.  
  2038.  
  2039.  
  2040.      PCL4C Users Manual                                        Page 34
  2041.  
  2042.       10.0 Other MarshallSoft Computing Products
  2043.  
  2044.       10.1 The Personal Protocol Library for C/C++
  2045.  
  2046.       The Personal Protocol Library for C (PPL4C) consists of a C/C++
  2047.       language library which implements XMODEM, XMODEM-CRC, XMODEM-1K,
  2048.       XMODEM-G, YMODEM, YMODEM-G, and ZMODEM file transfer protocols.  A
  2049.       script compiler and interpreter is also included which is capable of
  2050.       such tasks as automatically logging onto a BBS and downloading a file
  2051.       or retrieving mail.  Three example script programs are included.
  2052.  
  2053.       The protocol library (PPL4C) requires the Personal Communications
  2054.       Library for C (PCL4C).
  2055.  
  2056.       The Personal Protocol Library for C is available for $40 plus $5 S&H
  2057.       ($10 S&H overseas).
  2058.  
  2059.       10.2 The EMS Expanded Memory Library
  2060.  
  2061.       The EMS4C library implements version 3.2 of the LIM
  2062.       (Lotus-Intel-Microsoft) specification for expanded memory. It will
  2063.       run with either version 3.2 or 4.0 of the LIM specification.
  2064.  
  2065.       The EMM4C library (included with the EMS4C library) is an expanded
  2066.       memory manager which allows C programmers to allocate and free EMS
  2067.       (expanded) memory similiar to malloc and free in the standard C
  2068.       runtime library.  Both EMM4C and EMS4C require that your system be
  2069.       configured with expanded (EMS) memory. But, 386 & up systems can use
  2070.       extended memory as expanded memory.
  2071.  
  2072.       The EMS Expanded Memory Library for C is available for $35 plus $5
  2073.       S&H ($10 S&H overseas).
  2074.  
  2075.       10.3 Other Products
  2076.  
  2077.       Marshallsoft Computing, Inc. makes serial communications libraries
  2078.       for Windows (C/C++, Visual Basic, and DELPHI), Visual Basic (DOS),
  2079.       Power Basic (DOS), and Turbo/Borland Pascal.
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.      PCL4C Users Manual                                        Page 35
  2101.  
  2102.